take advantage of C++11 delete to block a default operator, and move a bunch of loop index declarations to the loop.
static void swap_wpthdr(struct wpthdr* wpthdr,
void (*swap16_func)(void*), void (*swap32_func)(void*))
{
- int i;
-
if (swap32_func != nullptr) {
swap32_func(&wpthdr->id);
}
if (swap16_func != nullptr) {
swap16_func(&wpthdr->num);
swap16_func(&wpthdr->next);
- for (i=0; i<MAXWPT; i++) {
+ for (int i=0; i<MAXWPT; i++) {
swap16_func(&wpthdr->idx[i]);
}
}
static void swap_rtehdr(struct rtehdr* rtehdr,
void (*swap16_func)(void*), void (*swap32_func)(void*))
{
- int i;
-
if (swap16_func != nullptr) {
swap16_func(&rtehdr->num);
swap16_func(&rtehdr->next);
- for (i=0; i<MAXRTE; i++) {
+ for (int i=0; i<MAXRTE; i++) {
swap16_func(&rtehdr->idx[i]);
}
swap16_func(&rtehdr->rteno);
static void swap_rte(struct rte* rte,
void (*swap16_func)(void*), void (*swap32_func)(void*))
{
- int i;
-
if (swap16_func != nullptr) {
swap16_func(&rte->wptnum);
- for (i=0; i<MAXWPTINRTE; i++) {
+ for (int i=0; i<MAXWPTINRTE; i++) {
swap16_func(&rte->wptidx[i]);
}
swap16_func(&rte->reserved);
static void str2lab(char* dest, const char* src, int len, const char* fmt,
int n)
{
- int i,j;
+ int j;
j = 0;
if (src != nullptr) {
- for (i=0; i<len && src[i] != '\0'; i++) {
+ for (int i=0; i<len && src[i] != '\0'; i++) {
if (isprint(src[i])) {
dest[j++] = src[i];
}
session_t* session; /* pointer to a session struct */
void* extra_data; /* Extra data added by, say, a filter. */
-private:
- Waypoint& operator=(const Waypoint& other);
-
public:
Waypoint();
~Waypoint();
Waypoint(const Waypoint& other);
+ // the default assignment operator is not appropriate as we do deep copy of some members,
+ // and we haven't bothered to write an appropriate one.
+ // Catch attempts to use the default assignment operator.
+ Waypoint& operator=(const Waypoint& other) = delete;
bool HasUrlLink() const;
const UrlLink& GetUrlLink() const;
QUEUE_FOR_EACH(&ifd->tags, elem, tmp) {
exif_tag_t* tag = (exif_tag_t*)elem;
if ((tag->size > 4) && (tag->value)) {
- uint16_t i;
char* ptr;
tag->data = xmalloc(tag->size);
if (BYTE_TYPE(tag->type)) {
gbfread(ptr, tag->count, 1, fin);
- } else for (i = 0; i < tag->count; i++) {
+ } else for (uint16_t i = 0; i < tag->count; i++) {
switch (tag->type) {
case EXIF_TYPE_SHORT:
case EXIF_TYPE_SSHORT:
exif_tag_t* tag = (exif_tag_t*)elem;
if (tag->size > 4) {
- uint16_t i;
char* ptr = (char*) tag->data;
if BYTE_TYPE(tag->type) {
gbfwrite(tag->data, tag->size, 1, fout);
- } else for (i = 0; i < tag->count; i++) {
+ } else for (uint16_t i = 0; i < tag->count; i++) {
switch (tag->type) {
case EXIF_TYPE_SHORT:
case EXIF_TYPE_SSHORT:
// gh561 (isSizeSwaped)
//2 <len_l> <len_h> <payload...> <crc>
- uint32_t i;
-
uint8_t crc = 0;
write_byte(2);
}
if (payload != nullptr) {
- for (i = 0; i < size; i++) {
+ for (uint32_t i = 0; i < size; i++) {
write_byte(payload[i]);
crc ^= payload[i];
}
static void
gtc_wr_init(const QString& fname)
{
- int i;
-
ofd = gbfopen(fname, "w", MYNAME);
if (opt_sport) {
- for (i = 0; i < MAX_SPORTS; i++) {
+ for (int i = 0; i < MAX_SPORTS; i++) {
if (0 == case_ignore_strncmp(opt_sport, gtc_sportlist[i], 2)) {
gtc_sport = i;
break;
{
humminbird_waypt_t hum;
double lat, north, east;
- int i;
int num_icons = sizeof(humminbird_icons) / sizeof(humminbird_icons[0]);
be_write16(&hum.num, waypoint_num++);
// Icon....
if (!wpt->icon_descr.isNull()) {
- for (i = 0; i < num_icons; i++) {
+ for (int i = 0; i < num_icons; i++) {
if (!wpt->icon_descr.compare(humminbird_icons[i], Qt::CaseInsensitive)) {
hum.icon = i;
break;
}
if (hum.icon == 255) { /* no success, no try to find the item in a more comlex name */
hum.icon = 0; /* i.e. "Diamond" as part of "Diamond, Green" or "Green Diamond" */
- for (i = 0; i < num_icons; i++) {
+ for (int i = 0; i < num_icons; i++) {
char* match;
int j;
xasprintf(&match, "*%s*", humminbird_icons[i]);
itracku_rd_ser_init(const QString& fname)
{
#if LATER
- int i;
if (0 == strcmp(qPrintable(fname), port_auto_detect_filename)) {
dbg(1, "auto detecting port for iTrackU device");
- for (i=1; !fd && i<port_auto_detect_max_port; ++i) {
+ for (int i=1; !fd && i<port_auto_detect_max_port; ++i) {
xasprintf(&port, "com%d", i);
if (!gbser_is_serial(port)) {
break;
fd = NULL;
xfree(port);
}
- for (i=0; !fd && i<port_auto_detect_max_port; ++i) {
+ for (int i=0; !fd && i<port_auto_detect_max_port; ++i) {
xasprintf(&port, "/dev/ttyUSB%d", i);
if (!gbser_is_serial(port)) {
break;
void
set_baudrate()
{
- int i;
int rc;
int baudrates[] = { 4800, 9600, 14400, 19200, 38400, 57600, 115200, 0 };
int baudrate;
} else {
dbg(1, "Probing for baudrate...\n");
- for (i=0;; i++) {
+ for (int i=0;; i++) {
baudrate = baudrates[i];
if (baudrate == 0) {
fatal(MYNAME ": Autobaud connection failed\n");
static int
rd_buf(const uint8_t* buf, int len)
{
- int rc, timeout, i;
+ int rc, timeout;
char dump[16*3+16+2];
/* Allow TIMEOUT plus the time needed to actually receive the data bytes:
if (global_opts.debug_level >= 4) {
db(4, "rd_buf(): dump follows:\n");
dump[sizeof(dump)-1] = 0;
- for (i = 0; i < (len+15)/16*16; i++) { // count to next 16-byte boundary
+ for (int i = 0; i < (len+15)/16*16; i++) { // count to next 16-byte boundary
if (i < len) {
snprintf(&dump[(i%16)*3], 4, "%02x ", buf[i]);
snprintf(&dump[3*16+1+(i%16)], 2, "%c", isprint(buf[i]) ? buf[i] : '.');
static void
write_blocks(gbfile* f, struct blockheader* blocks)
{
- int i;
write_char(f, 1);
write_long(f, blocks->size);
write_float_as_long(f, blocks->maxlon*100000);
write_blocks(f, blocks->ch2);
}
if (!blocks->ch1 && !blocks->ch2) {
- for (i = 0; i < blocks->count; i++) {
+ for (int i = 0; i < blocks->count; i++) {
char desc_field [256];
write_char(f, 2);
if (global_opts.smart_names &&
double ret;
char r[8];
const void* p;
- int i;
if (i_am_little_endian == read_le) {
p = ptr;
} else {
- for (i = 0; i < 8; i++) {
+ for (int i = 0; i < 8; i++) {
r[i] = ((char*)ptr)[7-i];
}
p = r;
float ret;
char r[4];
const void* p;
- int i;
if (i_am_little_endian == read_le) {
p = ptr;
} else {
- for (i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
r[i] = ((char*)ptr)[3-i];
}
p = r;
void
endian_write_double(void* ptr, double d, int write_le)
{
- int i;
char* optr = (char*) ptr;
// Word order is different on arm, but not on arm-eabi.
#if defined(__arm__) && !defined(__ARM_EABI__)
if (i_am_little_endian == write_le) {
memcpy(ptr, r, 8);
} else {
- for (i = 0; i < 8; i++) {
+ for (int i = 0; i < 8; i++) {
*optr++ = r[7-i];
}
}
endian_write_float(void* ptr, float f, int write_le)
{
char* r = (char*)(void*)&f;
- int i;
char* optr = (char*) ptr;
if (i_am_little_endian == write_le) {
memcpy(ptr, &f, 4);
} else {
- for (i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
*optr++ = r[3-i];
}
}
// note: extra_data is not deep copied.
}
-Waypoint& Waypoint::operator=(const Waypoint& /* other */)
-{
- // the default assignment operator is not appropriate as we do deep copy of some members,
- // and we haven't bothered to write an appropriate one.
- // this is a dummy so the compiler can catch attempts to use the assignment operator.
- return *this;
-}
-
bool
Waypoint::HasUrlLink() const
{